package com.activenetwork.smlite.testcase.events.createEvents.basics;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import com.activenetwork.custom.uielement.UIElement;
import com.activenetwork.custom.uielement.decorate.IdentifierFactory;
import com.activenetwork.schema.model.event.EventBasicType;
import com.activenetwork.smlite.page.event.EventDetailView.EventBasicSubview;
import com.activenetwork.smlite.snippet.EventsSnippet;
import com.activenetwork.smlite.testcase.BaseCase;
import com.activenetwork.util.EnvContext;
import com.activenetwork.util.verification.gson.FailurePoint;

public class Basics025 extends BaseCase {
	
	static final Logger logger = LoggerFactory.getLogger(Basics025.class);
	private EventBasicType eventBasic;
	
	@BeforeClass(alwaysRun = true)
	public void dataSetup(){
		eventBasic = new EventBasicType();
		EventBasicType.Location location = new EventBasicType.Location();
		eventBasic.setLocation(location);
		
		location.setLocationName("test location city region max length");
	}
	
	@Test
	public void Verify_CityRegion_maximum_length_is_50(){
		loginBusiness.login();
		
		EventBasicSubview eventBasicSubview = EventsSnippet.gotoAddEventPage();
		eventBasicSubview.setEventLocation(eventBasic);
		UIElement cityRegion = IdentifierFactory.createUIElement("EventBasicSubview", "locationCityRegion");
		String maxlen = cityRegion.getAttribute("maxlength");
		if(!StringUtils.equals(maxlen, "50")){
			EnvContext.failurePointTL.get().add(
					new FailurePoint(Basics025.class.getName(), 
					"Verify location city/region max length is 50", 
					"Location city/region max length is " + maxlen));
		}
		
		loginBusiness.logout();
	}

}
